import Vue from 'vue'
import Vuex from 'vuex'
import {transObj,transStr,rmInfo} from '../utils/saveInfo'

Vue.use(Vuex)
const userInfo = 'userInfo'

export default new Vuex.Store({


  state: {
    [userInfo]:transObj(userInfo)
  },
  mutations: {

    setInfo(state,payload){
      transStr(userInfo,payload)
      state[userInfo] = transObj(userInfo)
    },
    removeInfo(state){
      rmInfo(state,userInfo)
    }

  },
  actions: {
    changeInfo(mutations,payload){
      mutations.commit('setInfo',payload)
    },
    rmNowInfo(mutations){
      mutations.commit('removeInfo')

    }
  },
  modules: {
  }
})
